package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.EO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface EoMapper extends BaseMapper<EO> {

    @Select("select * from eo where quatation_id = #{id}")
    EO selectByQuatationId(String id);

    @Select("SELECT * FROM eo WHERE id IN (SELECT eo_id FROM eo_e_people WHERE people_id = #{peopleId}) " +
            "AND type = #{type} AND is_active is true ORDER BY start_time DESC")
    List<EO> pagePeople(Integer peopleId, String type);

    @Select("SELECT * FROM eo WHERE id IN (SELECT eo_id FROM eo_e_dept WHERE dept_id = #{departmentId}) " +
            "AND type = #{type} AND is_active is true ORDER BY start_time DESC")
    List<EO> pageDept(String departmentId, String type);
}
